{% extends 'base.html' %}

{% block body %}

<p>{{ 'This server is configured to store %d revisions per entry maximum.'|trans|format(App.Config.configArr.max_revisions) }}
{{ 'A change of at least %d characters is required to trigger a revision save.'|trans|format(App.Config.configArr.min_delta_revisions) }}</p>

{% set query = '?mode=view&' %}
<a href='{{ Entity.entityType.toPage ~ query }}id={{ Entity.id }}' class='btn hl-hover-gray'>
    <i class='fas fa-chevron-left mr-1'></i>{{ 'Go back'|trans }}
</a>
<div id='compareRevisionsDiv' class='mt-3' hidden>
  <button class='btn btn-secondary btn-sm' id='compareRevisionsButton' type='button' disabled data-action='compare-revisions' data-type='{{ Entity.entityType.value }}' aria-label='{{ 'Compare revisions'|trans }}'>
    <i class='fas fa-code-compare fa-fw mr-1 color-white'></i>{{ 'Compare revisions'|trans }}
  </button>
  <div id='compareRevisionsDiffDiv'></div>
</div>

<ul class='list-group mt-3'>
  {% for revision in revisionsArr %}
    {% set randomId = random() %}
    <li id='parent_{{ randomId }}' class='list-group-item'>
      <div class='d-flex'>
        <div>
          <input autocomplete='off' type='checkbox' data-action='checkbox-revision' data-id='{{ Entity.id }}' data-revid='{{ revision.id }}' data-type='{{ Entity.entityType.value }}' aria-label='{{ 'Select'|trans }}' class='mr-2' />
          <span title='{{ 'Revision ID'|trans }}' class='badge badge-secondary mr-2'>{{ revision.id }}</span>
          <span class='p-1 btn rounded hl-hover-gray' data-type='{{ Entity.entityType.value }}' data-id='{{ Entity.id }}' data-revid={{ revision.id }} data-randid={{ randomId }} data-action='toggle-body' data-opened-icon='fa-square-minus' data-closed-icon='fa-square-plus' title='{{ 'Toggle content'|trans }}'>
            <i class='fas fa-square-plus fa-fw'></i>
          </span>
          <span class='relative-moment' title='{{ revision.created_at }}'></span> {{ 'by'|trans }} {{ revision.fullname }}
        </div>
        <div class='ml-auto'>
          {% if not Entity.isReadOnly %}<button type='button' data-action='restore-revision' data-id='{{ Entity.id }}' data-type='{{ Entity.entityType.value }}' data-revid='{{ revision.id }}' class='btn hl-hover-gray'>{{ 'Restore'|trans }}</button>{% endif %}
        </div>
      </div>
      <div hidden id='{{ randomId }}' style='overflow:auto;margin: 10px 0 0 20px'><div></div></div>
    </li>
  {% endfor %}
</ul>

{% endblock body %}
